package com.sumainfor.wx.system.gmio.service;

import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.system.feign.BaseFeignEpc;
import com.sumainfor.wx.system.gmio.dao.TenantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Meng
 * @ClassName RepairService
 * @date 2019/8/12 16:27
 * @description: TODO 维修
 */
@Service
public class ApplyRepairService {

    @Autowired
    private BaseFeignEpc feignEpc;

    @Autowired
    private TenantMapper tenantMapper;

    /**
     * @Description //TODO 服务管家发起维修申请
     * @return com.sumainfor.common.util.JsonResult
     * @Param [params]
     * @Date 2019/8/12 16:29
     **/
    public JsonResult addRepair(Map<String, Object> params) {
        //取出房源id
        String houId = (String) params.get("HouId");
        String userId = ContextUtils.getUserId();
        Integer no = tenantMapper.getHouseNoByHouseIdAndSysId(houId, userId);
        if (no == 0) {
            return JsonResult.error("房源信息与操作管家不匹配");
        }
        return feignEpc.AddRepair(params);
    }
}
